<?php
	include_once 'metier/pictogram.dao.mysql.php';
	include_once 'metier/pictogram.class.php';
        
        
        
	$db = new myPDO();

        $tmpId = $_POST['identifiant'];

	$pictogram = new Pictogram($tmpId);
	$pictogramDAO = new PictogramDAO();
        
        
        $picto = new Pictogram ($tmpId);
        $pictoDAO = new PictogramDAO ();
        $c = $pictoDAO->find ($picto,$db);
        
       
        if ($c == 0 ) {
        // Si le pictogramme n'est pas associé à une activité
            
        $picto_img = $pictoDAO->findPictogram ($picto,$db);
        
        $img = $picto_img->getImage();
        
        $file = "../imagesPicto" ;
        unlink ($file."/".$img);
        
        $son = $picto_img->getSon();
        
        $file = "../sonPicto" ;
        unlink ($file."/".$son);

	$pictogramDAO->deletePictogram($pictogram, $db);
        }
        
        else {       
       echo 0;
        }
        
?>